use std::io::{self, BufRead};

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let parent = (0..n).collect();
        let size = vec![1; n];
        UnionFind { parent, size }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.parent[x] != x {
            self.parent[x] = self.find(self.parent[x]);
        }
        self.parent[x]
    }

    fn union(&mut self, x: usize, y: usize) {
        let root_x = self.find(x);
        let root_y = self.find(y);
        if root_x != root_y {
            if self.size[root_x] < self.size[root_y] {
                self.parent[root_x] = root_y;
                self.size[root_y] += self.size[root_x];
            } else {
                self.parent[root_y] = root_x;
                self.size[root_x] += self.size[root_y];
            }
        }
    }

    fn max_size(&self) -> usize {
        *self.size.iter().max().unwrap_or(&0)
    }
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines().map(|line| line.unwrap());

    let t: usize = lines.next().unwrap().parse().unwrap(); // 读取测试数据组数

    for _ in 0..t {
        let n: usize = lines.next().unwrap().parse().unwrap(); // 读取关系对数

        let mut uf = UnionFind::new(100000); // 用户编号从1到105
        for _ in 0..n {
            let line = lines.next().unwrap(); // 读取一行关系
            let mut iter = line.split_whitespace();
            let x: usize = iter.next().unwrap().parse().unwrap();
            let y: usize = iter.next().unwrap().parse().unwrap();
            uf.union(x - 1, y - 1); // 转换为0-based索引
        }

        println!("{}", uf.max_size()); // 输出最大朋友圈人数
    }
}
